import {LOGIN,LOGOUT} from "../mutationTypes"
import {doDelete} from "../../assets/js/utils/RequestUtils"

const state = {
  //当前用户
  currentUser: {
    name:"",
    roleName:"",
    unitsName:""
  },

  //是否需要登录，用于跳转登录页面
  needLogin: true
};

const mutations = {
  /* 已经登录 */
  [LOGIN](state, currentUser) {
    state.currentUser = currentUser;
    document.body.className = "hold-transition skin-blue sidebar-mini";
    state.needLogin = false;
  },

  /* 注销 */
  [LOGOUT](state) {
    doDelete("/sys/user/logout");
    localStorage.removeItem("tokenId");
    document.body.className = "hold-transition login-page";
    state.needLogin = true;
  }
};

export default {
  state,
  mutations
}



// WEBPACK FOOTER //
// ./src/store/modules/User.js